package edu.gmu.middleware;

import edu.gmu.streams.BlockOutputStream;
import edu.gmu.streams.BlockInputStream;
import java.io.Serializable;
import java.io.IOException;

/**
 * Message can be marshaled/unmarshaled to/from byte streams.
 * Essentially this is a custom serialization scheme.
 * 
 * @author  James H. Pope
 * @version $Revision:$ $Date:$
 */
public interface Message extends Serializable
{
    /**
     * Writes this objects attributes to the specified stream.
     *
     * @param stream to write this object to.
     * @exception IOException  if the underlying stream throws an exception.
     */
    public void marshal(BlockOutputStream output) throws IOException;

    /**
     * Reads this objects attributes from the specified stream.
     *
     * @param stream to create this object from.
     * @exception IOException  if the underlying stream throws an exception.
     */
    public void unmarshal(BlockInputStream input) throws IOException;
}
